<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改施工合同')" />
    <th:block th:include="include :: datetimepicker-css" />
    <th:block th:include="include :: bootstrap-fileinput-css"/>
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-contract-edit" th:object="${ytConstructionContract}">
            <input name="constructionId" th:field="*{constructionId}" type="hidden">
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">客户id：</label>
                <div class="col-sm-8">
                    <select class="form-control" name="params[name]" th:with="customer=${@CustomerMsgService.selectYtCustomerMsgList(null) }">
                        <option value="">所有</option>
                        <option th:each="c : ${customer}" th:text="${c.name}" th:value="${c.name}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">合同签订时间：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <input name="contractSigningTime" th:value="${#dates.format(ytConstructionContract.contractSigningTime, 'yyyy-MM-dd')}" class="form-control" placeholder="yyyy-MM-dd" type="text" required>
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    </div>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">录入系统时间：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <input name="inputSystemTime" th:value="${#dates.format(ytConstructionContract.inputSystemTime, 'yyyy-MM-dd')}" class="form-control" placeholder="yyyy-MM-dd" type="text" required>
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    </div>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">合同金额：</label>
                <div class="col-sm-8">
                    <input name="contractValue" th:field="*{contractValue}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">项目名称：</label>
                <div class="col-sm-8">
                    <input name="projectName" th:field="*{projectName}" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">合同文件上传：</label>
                <div class="col-sm-8">
                    <input type="hidden" name="uploadOfDocuments" th:field="*{uploadOfDocuments}">
                    <div class="file-loading">
                        <input class="form-control file-upload" id="uploadOfDocuments" name="file" type="file">
                    </div>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <th:block th:include="include :: bootstrap-fileinput-js"/>
    <script th:inline="javascript">
        var prefix = ctx + "system/contract";
        $("#form-contract-edit").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-contract-edit').serialize());
            }
        }

        $("input[name='contractSigningTime']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        $("input[name='inputSystemTime']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        $(".file-upload").each(function (i) {
            var val = $("input[name='" + this.id + "']").val()
            $(this).fileinput({
                'uploadUrl': ctx + 'common/upload',
                initialPreviewAsData: true,
                initialPreview: [val],
                maxFileCount: 1,
                autoReplace: true
            }).on('fileuploaded', function (event, data, previewId, index) {
                $("input[name='" + event.currentTarget.id + "']").val(data.response.url)
            }).on('fileremoved', function (event, id, index) {
                $("input[name='" + event.currentTarget.id + "']").val('')
            })
            $(this).fileinput('_initFileActions');
        });
    </script>
</body>
</html>